home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_1 / mod.mul < prev    next >
Text File  |  1995-03-23  |  2KB  |  60 lines

  1. Article 1362 of comp.sys.handhelds:
  2. Path: en.ecn.purdue.edu!noose.ecn.purdue.edu!samsung!uunet!mcsun!hp4nl!charon!cwi.nl
  3. From: jurjen@cwi.nl (Jurjen NE Bos)
  4. Newsgroups: comp.sys.handhelds
  5. Subject: Modulo computations on 48SX
  6. Keywords: Number theory
  7. Message-ID: <2131@charon.cwi.nl>
  8. Date: 18 Sep 90 08:18:24 GMT
  9. Sender: news@cwi.nl
  10. Organization: STORC, Veldhoven
  11. Lines: 45
  12.  
  13. This article is meant for factorization and number theory freaks.
  14. I wrote a machine code program that does modulo multiplication for
  15. binaries.  The program is equivalent to the RPL
  16. \<< ROT ROT * SWAP DUP2 / * - \>>,
  17. except that the latter program only works if the intermediate product is
  18. smaller than 2^64.
  19. This machine code version does not have this problem.
  20.  
  21. Convert it with Bill Wickes' program ASC\->, and store in MULMOD.
  22. "D9D200FE8111920BBB00CCD20470008FD8F35100208F2D7608FD8F35101208F2
  23. D7608FD8F35AF8119AF7118AF082281F83201A704709F250B7AA754709F550B7
  24. 197F6D8D59E35B21305C54"
  25.  
  26. (28S owners please wait: I am working on a 28S version.)
  27. Usage:
  28. enter #a #b #m MULMOD to get (#a*#b) MOD #m
  29. All arguments must be binaries.
  30. #a must be < #m to make sure that the result is < #m.
  31. #b and #m are unrestricted.
  32. All arguments are checked, so that you don't have to be afraid for
  33. mistakes.  You'll get a nice "Too Few Arguments" or "Bad Argument Type"
  34. if applicable.
  35.  
  36. Remark: it is only tested on a version D.
  37. If you have another version, you're probably safe.  To be sure, check
  38. out memory location 53F8D.  It should contain 174E773DF1C4143 for the
  39. program to work.
  40.  
  41. A nice example of the use of MULMOD is the "Random imitator".
  42. The random generator uses internally a seed of 15 digits, and can be
  43. imitated using the program:
  44. \<< #2851130928467d R #1000000000000000 MULMOD DUP 'R' STO B->R 1E15 /
  45. \>>
  46. Seed the random generator by replacing
  47.     .xxxxxxxxxxxxEyy RDZ
  48. by
  49.     #xxxxxxxxxxxxyy1 'R' STO
  50. You can also produce the reverse of the random sequence replacing
  51. the factor 2851130928467 by 953992389123803.
  52. Have fun!
  53. --
  54. |                 | "Never imagine yourself not to be otherwise than what |
  55. | Jurjen N.E. Bos | it might appear to others that what you were or might |
  56. |                 | have been was not otherwise than what you had been    |
  57. |  jurjen@cwi.nl  | would have appeared to them to be otherwise."         |
  58.  
  59.  
  60.